//********
/*!

   \file

   \brief
      Contains entirely Windows-specific utility functions and classes.

   © 2011 Mark W. Gabby II
*/
#pragma once

#define WIN32_LEAN_AND_MEAN
#define WINVER 0x501 // Windows XP
#include <windows.h>

#include <gl/gl.h>
#include <gl/wglext.h>

#include "Platform.hpp"
#include "typedefs.hpp"
#include "GlobalConstants.hpp"

/*!
   \brief
      When this class is created, it creates an OpenGL context which is automatically destroyed
      when it goes out of scope.
*/
class ScopedOpenGLContext
{
public:
   ScopedOpenGLContext();
   ~ScopedOpenGLContext();

   void Init( const uint32_t PixelFormatIndex = kNull32 );

   bool IsCurrent();
   void MakeCurrent();

   HDC GetDC() { return ::GetDC( windowHandle ); }
   void ReleaseDC( HDC DeviceContext ) { ::ReleaseDC( windowHandle, DeviceContext ); }
   HGLRC GetHGLRC() { return openGLContextHandle; }
private:
   HWND windowHandle;
   HGLRC openGLContextHandle;
};

